package com.ifonly.activerecord.callback;

import com.ifonly.cache.invoke.CacheInvocation;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author ifonly
 * @version 1.0 2016-01-20 17:00
 * @since JDK 1.6
 */
public class ModelCacheInvocation extends CacheInvocation {
    private MethodProxy methodProxy;

    public ModelCacheInvocation(Object target, Method method, Object... args) {
        super(target, method, args);
    }

    public void setMethodProxy(MethodProxy methodProxy) {
        this.methodProxy = methodProxy;
    }

    @Override
    public void methodInvoke() {
        try {
            this.result = methodProxy.invokeSuper(target, args);
            this.methodInvoked = true;
        } catch (Throwable throwable) {
            throw new RuntimeException(throwable);
        }
    }
}
